package com.enzoism.springboot.kafka.listener;

import com.enzoism.springboot.kafka.model.UserModel;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class ConsumerListener {

    @KafkaListener(topics = "testTopic")
    public void onMessage(String message){
        // 1)insertIntoDb(buffer);//这里为插入数据库代码
        // 2)获取传递的参数，调用远程服务
        System.out.println("----->kafka消费者String："+message);
    }

    @KafkaListener(topics = "userTopic")
    public void onMessage(UserModel user){
        //insertIntoDb(buffer);//这里为插入数据库代码
        System.out.println("----->kafka消费者User："+user);
    }


}